package w83a.w83aManager;


import java.io.Serializable;

import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;

import w83a.w83aUtilidadesComunes.W83AProperties;
import w83a.w83aUtilidadesComunes.W83AWebServiceCall;
import w83a.w83aUtilidadesComunes.W83aClsTrazas;




public class W83ACatalogo implements Serializable{


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String dameDatosProcedimientoAll(String sessionToken,
			String procedureID) throws Exception {
		String result="";
		
		W83aClsTrazas.trazaError(null, " ----- EN dameDatosProcedimientoAll ----- ",new Exception());//NOPMD
		
		if (W83AProperties.getProperty("w83a","catalogoProc.ACTIVE").equals("true")){
				
			
			//W83ATrazas.depura("getProcedureTelActionForms");
	
			/** *** LLAMADA CON SOAP ****** */
			MessageFactory mfactory = MessageFactory.newInstance();
			SOAPMessage message = mfactory.createMessage();
			SOAPPart soapPart = message.getSOAPPart();
			SOAPEnvelope envelope = soapPart.getEnvelope();
	
			SOAPBody body = envelope.getBody();
		
			Name name = envelope.createName(W83AProperties.getProperty("w83a",
					"q99r.ws.getProcedureTelActionForms"), "",
					"http://www.openuri.org/");
	
			SOAPBodyElement element = body.addBodyElement(name);
	
			SOAPElement symbol = element.addChildElement(envelope
					.createName("sSessionToken"));
			symbol.addTextNode(sessionToken);
	
			symbol = element.addChildElement(envelope.createName("sProcedureId"));
			symbol.addTextNode(procedureID);
	
		/*	symbol = element.addChildElement(envelope
					.createName("sTelematicActionId"));
			symbol.addTextNode(W83AProperties.getProperty("w83a",
					"subctx.idSolicitud"));
	*/
			SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
			SOAPConnection con = factory.createConnection();
	
			
			String url = W83AProperties.getProperty("w83a", "url.ws.Q99rCPFacadeP");
			
			W83aClsTrazas.trazaError(null, " ----- URL dameDatosProcedimientoAll: "+url,new Exception());//NOPMD
	
			SOAPMessage responseWebServ = con.call(message, url);
	
			result = W83AWebServiceCall.getResultado(responseWebServ);
	
			
			W83aClsTrazas.trazaError(null, " ----- RESULTADO dameDatosProcedimientoAll: "+result,new Exception());//NOPMD
			
			/** *** FIN DE LLAMADA CON SOAP ****** */
	
			//W83ATrazas.depura("Rtdo. datos procedimiento-->" + result);
		}else{
			result="<Procedure xmlns=com/ejie/cp/xml><certifiedValidationMode>ASYNC</certifiedValidationMode><departmentId>8</departmentId><departmentName><description><language locale=eu>ENPLEGUA ETA GIZARTE POLITIKAK</language><language locale=es>EMPLEO Y POLÍTICAS SOCIALES</language></description></departmentName><daDocSeriesDependsOnProvince>S</daDocSeriesDependsOnProvince><daDocumentalSeries01><ID>2015</ID><shortDescription>TR.03.ESA</shortDescription><longDescription>Elecciones sindicales de Alava</longDescription></daDocumentalSeries01><daProcedureID>00635</daProcedureID><entityCode>04833001</entityCode><FamilyId>REGIST</FamilyId><inicioOficioCode>N</inicioOficioCode><languajeId>2</languajeId><languajeTypeId>2</languajeTypeId><managingUnitId>2343</managingUnitId><managingUnitName><description><language locale=eu>LAN ETA GIZARTE SEGURANTZA ZUZENDARITZA</language><language locale=es>DIRECCION DE TRABAJO Y SEGURIDAD SOCIAL</language></description></managingUnitName><organismId>1</organismId><procedureId>w83a_elecc_sindic</procedureId><ProcedureInboxId>EJ00617M</ProcedureInboxId><ProcedureInboxName>María López de Foronda</ProcedureInboxName><procedureName><description><language locale=eu>Elecciones Sindicales_EU</language><language locale=es>Elecciones Sindicales</language></description></procedureName><procedureStatus>A</procedureStatus><RequestSignatureCode>S</RequestSignatureCode><telematicscode>N</telematicscode><useBeginingDate>01-01-2010 00:00:00</useBeginingDate><useFinalDate>30-06-2070 00:00:00</useFinalDate><localizationSystemId>F</localizationSystemId><procedureW93B>00635</procedureW93B><subprocedureW93B>Sin Procedimiento asociado</subprocedureW93B><pnpCode>N</pnpCode></Procedure>";	
		}
		return result;
	}


}